$(".submit").on('click', function () {
    var username = $.trim($("#username").val());
    var pwd = $.trim($("#password").val());
    if (username == "" || pwd == "") {
        alert('用户名或密码不能为空');
    } else {
        login(username, pwd);
    }
});

function login(username, pwd) {
    var user = "";
    if (username == "admin") {
        user = "0123456789";
    }
    var params = JSON.stringify({"phoneNumber": user, "password": pwd});
    $.ajax({
        // url:'http://125.65.40.171/conference-check/conventionerController/login',
        url: 'conventionerController/login',
        dataType: 'json',
        data: {"param": params},
        type: "post",
        xhrFields: {
            withCredentials: true
        },
        success: function (data) {
            if (data.code == 200) {
                window.location.href = "manage";
            } else {
                alert("用户名错误");
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert('系统错误');
        }
    })
}

// function setSession() {
//     $.ajax({
//         url:'adminSession',
//         dataType:'json',
//         data:{"flging":Math.random()},
//         type:"post",
//         success:function (data) {
//             if(data==200){
//                 window.location.href="manage";
//             }else{
//                 alert('系统错误，请稍后重试');
//             }
//         },
//         error:function (XMLHttpRequest,textStatus,errorThrown) {
//             alert('系统错误，请稍后重试');
//         }
//     })
// }